﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Happy.Archetype;
using Happy.Domain;

namespace Happy.Security.Domain.Users
{
    [DomainModel, Party]
    public class User : AggregateRoot<Guid>
    {
        private User() { }

        internal User(Guid id, string username, string password)
            : base(id)
        {
            this.UserName = username;
            this.Password = password;
        }

        public string UserName { get; private set; }

        public string Password { get; private set; }

        public string PasswordQuestion { get; private set; }

        public string PasswordAnswer { get; private set; }

        public string Email { get; private set; }

        public bool IsApproved { get; private set; }

        public bool IsLockedOut { get; private set; }

        public bool IsOnline { get; private set; }

        public DateTime? LastActivityDate { get; private set; }

        public DateTime? LastLockoutDate { get; private set; }

        public DateTime? LastLoginDate { get; private set; }

        public DateTime? LastPasswordChangedDate { get; private set; }

        internal void ChangePassword(string password)
        {
            this.Password = password;
            this.LastPasswordChangedDate = DateTime.Now;
        }
    }
}
